package 力扣._6_N字形变换;

public class Solution {
    public String convert(String s, int numRows) {
        StringBuilder[] stringBuilders = new StringBuilder[numRows];
        for (int i = 0; i < numRows; i++) {
            stringBuilders[i] = new StringBuilder();
        }
        int i = 0, j = 0;
        while (j < s.length()) {
            for (i = 0; i < numRows && j < s.length(); i++)
                stringBuilders[i].append(s.charAt(j++));

            for (i = numRows - 2; i >= 1 && j < s.length(); i--)
                stringBuilders[i].append(s.charAt(j++));
        }
        for (i = 1; i < stringBuilders.length; i++) {
            stringBuilders[0].append(stringBuilders[i]);
        }
        return stringBuilders[0].toString();
    }

    public static void main(String[] args) {
        String convert = new Solution().convert("PAYPALISHIRING", 3);
        System.out.println(convert);


    }
}
